package com.llbnk.service;

import com.llbnk.error.BusinessException;
import com.llbnk.pojo.model.ItemModel;

import java.util.List;

/**
 * @author llbnk
 * @create 2022-08-21 16:15
 */
public interface ItemService {

    //创建预约活动
    ItemModel createItem(ItemModel itemModel) throws BusinessException;

    //预约活动列表浏览
    List<ItemModel> listItem();

    //预约活动详情浏览
    ItemModel getItemById(Integer id);

    //预约活动库存扣减
    boolean decreaseStock(Integer itemId, Integer amount);

    //负责异步情况下库存扣减工作
    boolean asynchronousDecreaseStock(Integer itemId, Integer amount);

    //负责异步情况下库存扣减工作
    boolean SoldOutAsynDecreaseStock(Integer itemId, Integer amount);

    //负责异步情况下库存回滚操作配合asynchronousDecreaseStock
    boolean asynchronousIncreaseStock(Integer itemId, Integer amount);

    //预约活动销量增加
    void increaseSales(Integer itemId, Integer amount);

    //用于createOrder中防止decreaseStock多扣库存问题，开发出新的异步更新库存
    boolean asyncDecreaseStock(Integer itemId, Integer amount);

    //item和promo model缓存模型:验证商品和活动是否有效
    ItemModel getItemByIdInCache(Integer id);

    //初始化库存流水
    String initStockLog(Integer itemId, Integer amount);

}
